import request from '../../../utils/request'
import type { AttrObj, AttrResponse, CateResponseData } from './type'
enum API {
  C1_URL = '/admin/product/getCategory1',
  C2_URL = '/admin/product/getCategory2/',
  C3_URL = '/admin/product/getCategory3/',
  ATTRS_URL = '/admin/product/attrInfoList/',
  OPERATEATTRS_URL = '/admin/product/saveAttrInfo',
}

// 默认返回此条执行语句的结果
export const reqC1Category = () => request.get<CateResponseData>(API.C1_URL)

export const reqC2Category = (id: number | string) =>
  request.get<CateResponseData>(API.C2_URL + id)

export const reqC3Category = (id: number | string) =>
  request.get<CateResponseData>(API.C3_URL + id)

export const reqAttrs = (
  c1: number | string,
  c2: number | string,
  c3: number | string,
) => request.get<AttrResponse>(`${API.ATTRS_URL}${c1}/${c2}/${c3}`)

export const reqOperateAttrs = (data: AttrObj) =>
  request.post<any>(API.OPERATEATTRS_URL, data)
